package com.yxzr.youyou.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.yxzr.youyou.R;
import com.yxzr.youyou.utils.AppManager;
import com.yxzr.youyou.utils.StatusBarUtil;

public class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StatusBarUtil.setStatusBarColor(this, R.color.main_color);
        AppManager.getInstance().addActivity(this); //添加到栈中
    }
    /**
     * 设置包含返回键的标题
     *
     */
    public void setTitleWithBack() {
        if (findViewById(R.id.iv_common_back)!=null){
            ImageView backIv = (ImageView) findViewById(R.id.iv_common_back);
            backIv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
        }
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        AppManager.getInstance().finishActivity(this); //从栈中移除
    }
}
